package com.dragon.modules.yuegou.enums.code;

import com.dragon.common.constant.enums.IBusinessCode;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 会员业务状态码
 * 
 * @author 刘武
 *
 */
public enum PointsCode implements IBusinessCode {

	MERCHANT_RATE_EXISTS(19000,"存在商户已配比积分"),

	FIRSTBTYPE_NOTNULL(19001,"一级业态不能为空"),

	SECONDBTYPE_NOTNULL(19002,"二级业态不能为空"),

	MERCHANT_NOTNULL(19003,"商户不能为空"),

	MONEY_NOTNULL(19004,"配比金额不能为空"),

	MONEY_FORMAT(19005,"配比金额格式不正确"),

	POINTS_NOTNULL(19006,"配比积分不能为空"),

	POINTS_FORMAT(19007,"配比积分必须是正整数"),

	POINTS_INSUFFICIENT(19009, "会员积分不足"),

	APPLY_TYPE_NOTNULL(19010, "小票类型不能为空"),

	COST_NOTNULL(19011, "消费金额不能为空"),

	TICKET_PIC_NOTNULL(19012, "小票地址不能为空"),

	SKUID_ERROR(19014, "商品不存在，或不是积分商品"),

	BUSDID_ERROR(19015, "商圈不存在，或商圈配置错误"),

	UNDERSTOCK(19016, "库存不足"),

	ORDERNO_NOTNULL(19017,"订单号为空"),

	ORDERNO_NOT_EXIST(19018,"订单不存在"),

	APPLY_CHECKED(19019,"该申请已审核，不能再次审核"),

	REWARDS_POINTS_NOTNULL(19020,"奖励积分不能为空"),

	REWARDS_POINTS_FORMAT(19021,"奖励积分必须是正整数"),

	RULE_DAYS_NOTNULL(19022,"连签天数不能为空"),

	RULE_DAYS_FORMAT(19023,"连签天数必须是正整数"),

	SIGN_EXPLAIN_NOTNULL(19024,"签到说明不能为空"),

	RULE_DAYS_REPEAT(19025,"连签天数不能重复"),

	SIGN_ALREADY(19026,"您今日已签到"),

	SIGN_RELUS_UNCONFIGURATION(19027,"商圈尚未配置签到规则"),

	MEMBER_ISNULL(19028,"会员积分信息不存在"),

	POINTS_NOTENOUGH(19029,"积分不足，不能支出积分"),

	NOT_POINTS_RATE(19030,"该商铺未配置积分规则"),

	NOT_MEMBER_POINTS_RATE(19031,"该商圈未配置会员积分规则"),

	COST_SMALL(19032, "消费金额过小"),
	
	MAX_NUM_CEILING(19033, "当日兑换次数已用完"),
	
	MAX_POINT_CEILIN(19034, "当日可兑换积分上限不足"),
	
	NOT_NULL_POINT(19035, "请确认积分"),
	
	CLEAR_DATE_MUST_AFTER_NOW(19036, "积分清理时间必须在当前时间之后"),
	
	CANCEL_TASK_FAIL(19037, "取消积分清理任务失败"),
	
	NOT_CONFIG_MEMBER_LEVEL(19038,"该商圈未配置会员等级"),
	
	WX_SHOP_CONFIG_ERROR(19040,"微信商户配置重复"),

	RATIOLIST_IS_EMPTY(19041,"请选择配比类型"),
	BEGIN_TIME_BIG_END_TIME(19042,"开始时间必须小于结束时间"),
	BEGIN_TIME_LESS_NOW(19043,"开始时间必须大于当前时间"),
	REPETITION_POINT(19044,"已有活动，请重新设置"),
	ALL_GOODS_NOT_STOCK(19045, "所有商品都没有库存"),

	EXIST_GOODS_NOT_STOCK(19046, "存在商品都没有库存"),

	INSUFFICIENT_INVENTORY(19047, "%s商品库存不足"),
	G2_PRIZE_TITLE_REPEAT(19048, "虚拟产品的奖品标题不能重复"),
	G1_GOODS_REPEAT(19049, "实物产品存在商品重复"),
	CANNOT_BE_LESS_THAN_ERROR(19050, "变更后总数不能小于0"),
	INSUFFICIENT_INVENTORY_TWO_ERROR(19051, "%s商品可用库存为%s,奖品总数需小于等于可用库存"),
	PLEASE_DISABLE_AFTER_DELETE(19052, "请禁用该活动再删除"),
	INSUFFICIENT_INVENTORY_2_ERROR(19053, "%s商品可用库存为%s,已配置奖品库存为%s,奖品总数需小于等于可用库存"),
	NUM_ERROR(19054, "参数传递错误，商品总数不等于剩余数量+中奖数量"),
	POINT_STOP_ERROR(19055, "平台积分已停止，不能继续停止"),
	/**
	 * 状态码说明
	 */
	TODO(19999, "提示消息");
	
	private final Integer code;

	private final String message;

	private PointsCode(Integer code, String message) {
		this.code = code;
		this.message = message;
	}

	public Integer getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	/**
	 * 把code转化为ResponseCode枚举
	 * 
	 * @param code 代码
	 * @return
	 */
	public static PointsCode from(Integer code) {
		if (code == null) {
			return null;
		}
		return CODE_MAP.get(code);
	}

	/**
	 * Code Map for ResponseCode
	 */
	private static final Map<Integer, PointsCode> CODE_MAP = Stream.of(PointsCode.values())
			.collect(Collectors.toMap(PointsCode::getCode, e -> e));
	
}
